Obtaining Section Number for an Object

The Object Number attribute in full is 3.1.7.2.4.1

I want it to return just 3

The only way I can see of doing this is to find the first non-alphanumeric character and strip away everything from there to the end.

Is that really the way to do it, or is there an attribute value for "Section Number" or similar ?


Dartguru - Tue Aug 02 10:34:50 EDT 2016

Re: Obtaining Section Number for an Object
DOORSHAM - Tue Aug 02 20:34:25 EDT 2016

Check this out: https://www.ibm.com/developerworks/community/forums/html/topic?id=9fcfb0d5-187e-4d5a-8838-52da85aaed32&ps=25

Re: Obtaining Section Number for an Object
PekkaMakinen - Wed Aug 03 01:13:27 EDT 2016

The function number returns a string and a string is an array of characters. You get the first character of the array by indexing it with zero (this returns a character, not a string so in the example I have to concatenate with an empty string to get it displayed)

So in Layout DXL

string ObjectNumber = number(obj)
string SectionNumber = ObjectNumber[0] ""
display SectionNumber

Re: Obtaining Section Number for an Object
Antonio__Norkus - Wed Aug 03 08:00:19 EDT 2016

PekkaMakinen - Wed Aug 03 01:13:27 EDT 2016

The function number returns a string and a string is an array of characters. You get the first character of the array by indexing it with zero (this returns a character, not a string so in the example I have to concatenate with an empty string to get it displayed)

So in Layout DXL

string ObjectNumber = number(obj)
string SectionNumber = ObjectNumber[0] ""
display SectionNumber

How about for sections higher than 9?

I think it would be better to use a regular expression to extract the section number.

Here is an example Layout DXL to display in a column:

Regexp sectionNum = regexp2 "([0-9]+)\\."
string objNum = number(obj)
if (sectionNum(objNum)) display objNum[match 1]

 

Re: Obtaining Section Number for an Object
PekkaMakinen - Wed Aug 03 08:03:39 EDT 2016

Antonio__Norkus - Wed Aug 03 08:00:19 EDT 2016

How about for sections higher than 9?

I think it would be better to use a regular expression to extract the section number.

Here is an example Layout DXL to display in a column:

Regexp sectionNum = regexp2 "([0-9]+)\\."
string objNum = number(obj)
if (sectionNum(objNum)) display objNum[match 1]

 

Yes, you are correct, that is a better solution

Re: Obtaining Section Number for an Object
Dartguru - Thu Aug 04 04:55:58 EDT 2016

Antonio__Norkus - Wed Aug 03 08:00:19 EDT 2016

How about for sections higher than 9?

I think it would be better to use a regular expression to extract the section number.

Here is an example Layout DXL to display in a column:

Regexp sectionNum = regexp2 "([0-9]+)\\."
string objNum = number(obj)
if (sectionNum(objNum)) display objNum[match 1]

 

Excellent Antonio, that's exactly what I was after.

Re: Obtaining Section Number for an Object
Adamarla - Tue Aug 30 04:51:58 EDT 2016

I'd just do it with intOf:

print intOf(number(o))

That avoids the overhead of creating and deleting a regexp